/*
Realistic Unit Modification v4.0 Dialog 
v4.0.0.1 [ALPHA]
Concept & Development by Draper & Raps | [VRC]
*/

// For Dialog
// Buttons ----------------------------

RUM_BttnArty = {
	RUM_Arty_disstg = ctrlText RUM_DistArty_IDC;
	RUM_Arty_dirstg = ctrlText RUM_DegrArty_IDC;
	RUM_Arty_updnstg = ctrlText RUM_UpDnArty_IDC;
	RUM_Arty_totstg = ctrlText RUM_ToTArty_IDC;
	RUM_Arty_typeid = lbCurSel RUM_TypeArty_IDC;
	RUM_Arty_typRid2 = lbCurSel RUM_typRArty_IDC;
	RUM_Arty_typRid = lbText [RUM_typRArty_IDC,RUM_Arty_typRid2];
	RUM_Arty_numRid = lbCurSel RUM_numRArty_IDC;
	RUM_Arty_timeid = lbCurSel RUM_TimeArty_IDC;
	RUM_Arty_battid = lbCurSel RUM_ListArty_IDC;
	RUM_Arty_mtarid2 = lbCurSel RUM_MTarArty_IDC;
	RUM_Arty_mtarid = lbText [RUM_MTarArty_IDC,RUM_Arty_mtarid2];
	RUM_Arty_dispid = lbCurSel RUM_DispArty_IDC;
	RUM_Arty_ctarid = lbCurSel RUM_CTarArty_IDC;
	if(RUM_Arty_typeid == 4) then {
		[RUM_Arty_battid] execVM (RUM_PATH+"Arty\scoot.sqf");
	}else{
		[RUM_Arty_typeid,RUM_Arty_typRid,RUM_Arty_numRid,RUM_Arty_timeid,RUM_Arty_battid,RUM_Arty_mtarid,RUM_Arty_dispid,RUM_Arty_ctarid,RUM_Arty_totstg] execVM (RUM_PATH+'Arty\callforfire.sqf');
	};
	if(true)exitWith{closeDialog 0};
};

RUM_CloseBttnArty = {
	RUM_Arty_disstg = ctrlText RUM_DistArty_IDC;
	RUM_Arty_dirstg = ctrlText RUM_DegrArty_IDC;
	RUM_Arty_updnstg = ctrlText RUM_UpDnArty_IDC;
	RUM_Arty_totstg = ctrlText RUM_ToTArty_IDC;
	RUM_Arty_typeid = lbCurSel RUM_TypeArty_IDC;
	RUM_Arty_typRid = lbCurSel RUM_typRArty_IDC;
	RUM_Arty_numRid = lbCurSel RUM_numRArty_IDC;
	RUM_Arty_timeid = lbCurSel RUM_TimeArty_IDC;
	RUM_Arty_battid = lbCurSel RUM_ListArty_IDC;
	RUM_Arty_mtarid2 = lbCurSel RUM_MTarArty_IDC;
	RUM_Arty_mtarid = lbText [RUM_MTarArty_IDC,RUM_Arty_mtarid2];
	RUM_Arty_dispid = lbCurSel RUM_DispArty_IDC;
	RUM_Arty_ctarid = lbCurSel RUM_CTarArty_IDC;
	if(true)exitWith{closeDialog 0};
};

RUM_ArtyMap = {
private ["_color","_array","_bat","_callsign","_max","_min","_stg1","_stg1b","_stg2","_stg3","_mkr1","_mkr1b","_mkr2","_mkr3"];
	RUM_Arty_colorcount = RUM_Arty_colorcount + 1;
	_color = "";
	switch (RUM_Arty_colorcount) do {
		case 0: {
			_color = "ColorBlack";
		};
		case 1: {
			_color = "ColorRed";
		};
		case 2: {
			_color = "ColorGreen";
		};
		case 3: {
			_color = "ColorBlue";
		};
		case 4: {
			_color = "ColorYellow";
		};
		case 5: {
			_color = "ColorOrange";
			RUM_Arty_colorcount = 0;
		};
	};
	
	RUM_Arty_typRid = lbCurSel RUM_typRArty_IDC;
	RUM_Arty_battid = lbCurSel RUM_ListArty_IDC;
	_array = RUM_ArtyBatts select RUM_Arty_battid;
	_bat = _array select 0;
	_callsign = _array select 1;
	
	_max = _bat getVariable "ARTY_MAX_RANGE";
	_min = _bat getVariable "ARTY_MIN_RANGE";
	
	_stg1 = format ["%1_minrange",_bat];
	_stg1b = format ["%1_minrangeb",_bat];
	_stg2 = format ["%1_maxrange",_bat];
	_stg3 = format ["%1_center",_bat];
	
	_mkr1 = createMarkerLocal [_stg1, getPos _bat];
	_mkr1 setMarkerShapeLocal "ELLIPSE";
	_mkr1 setMarkerSizeLocal [_min, _min];
	_mkr1 setMarkerColorLocal _color;
	_mkr1 setMarkerBrushLocal "CROSS";
	_mkr1b = createMarkerLocal [_stg1b, getPos _bat];
	_mkr1b setMarkerShapeLocal "ELLIPSE";
	_mkr1b setMarkerSizeLocal [_min, _min];
	_mkr1b setMarkerColorLocal _color;
	_mkr1b setMarkerBrushLocal "BORDER";
	_mkr2 = createMarkerLocal [_stg2, getPos _bat];
	_mkr2 setMarkerShapeLocal "ELLIPSE";
	_mkr2 setMarkerSizeLocal [_max, _max];
	_mkr2 setMarkerColorLocal _color;
	_mkr2 setMarkerBrushLocal "BORDER";
	_mkr3 = createMarkerLocal [_stg3, getPos _bat];
	_mkr3 setMarkerShapeLocal "ICON";
	_mkr3 setMarkerTypeLocal "mil_dot";
	_mkr3 setMarkerTextLocal _callsign;
	_mkr3 setMarkerColorLocal _color;
	
	if(true)exitWith{closeDialog 0;openMap [true, false]};
};

RUM_ArtyMapNeg = {	
private ["_array","_bat","_stg1","_stg1b","_stg2","_stg3"];
	RUM_Arty_typRid = lbCurSel RUM_typRArty_IDC;
	RUM_Arty_battid = lbCurSel RUM_ListArty_IDC;
	_array = RUM_ArtyBatts select RUM_Arty_battid;
	_bat = _array select 0;
	
	_stg1 = format ["%1_minrange",_bat];
	_stg1b = format ["%1_minrangeb",_bat];
	_stg2 = format ["%1_maxrange",_bat];
	_stg3 = format ["%1_center",_bat];
	
	deleteMarker _stg1;
	deleteMarker _stg1b;
	deleteMarker _stg2;
	deleteMarker _stg3;
	
	if(true)exitWith{};
};

// Lists ------------------------------
RUM_TypRUpdate = {
private ["_dialog","_RUMtype","_tst","_sel","_type"];
	_dialog = _this select 0;
	_RUMtype = "";
	_tst = 0;
	while {_dialog} do {
		_sel = lbCurSel RUM_ListArty_IDC;
		if!(_sel == -1)then{
			_array = RUM_ArtyBatts select _sel;
			_type = _array select 2;
			switch (_type) do {
				case "howitzer": {
	//				hint "howitzer";
					if !(_type == _RUMtype) then {
						lbClear RUM_TypRArty_IDC;
						{lbAdd [RUM_TypRArty_IDC,_x]} foreach RUM_Arty_stype_howitzer;
						lbSetCurSel [RUM_TypRArty_IDC, 0];
					};
					_RUMtype = _type;
				};
				case "mortar": {
	//				hint "mortar";
					if !(_type == _RUMtype) then {
						lbClear RUM_TypRArty_IDC;
						{lbAdd [RUM_TypRArty_IDC,_x]} foreach RUM_Arty_stype_mortar;
						lbSetCurSel [RUM_TypRArty_IDC, 0];
					};
					_RUMtype = _type;
				};
				case "mlrs": {
	//				hint "mlrs";
					if !(_type == _RUMtype) then {
						lbClear RUM_TypRArty_IDC;				
						{lbAdd [RUM_TypRArty_IDC,_x]} foreach RUM_Arty_stype_mlrs;
						lbSetCurSel [RUM_TypRArty_IDC, 0];
					};
					_RUMtype = _type;
				};
				default {
				};
			};
		};
		_tst = _sel;
	};
	if(true)exitWith{};
};

RUM_NumRTimeUpdate = {
private ["_dialog","_RUMtype","_tst","_select"];
	_dialog = _this select 0;
	_RUMtype = 9;
	_tst = 0;
	while {_dialog} do {
		_select = lbCurSel RUM_TypeArty_IDC;
		if!(_select == -1)then{
			switch (_select) do {
				case 0: {
	//				hint "af";
					if !(_select == _RUMtype) then {
						lbClear RUM_NumRArty_IDC;				
						{lbAdd [RUM_NumRArty_IDC,_x]} foreach ["1"];
						lbSetCurSel [RUM_NumRArty_IDC, 0];
					};
					if !(_select == _RUMtype) then {
						lbClear RUM_TimeArty_IDC;				
						{lbAdd [RUM_TimeArty_IDC,_x]} foreach ["N/A"];
						lbSetCurSel [RUM_TimeArty_IDC, 0];
					};
					_RUMtype = _select;
				};
				case 1: {
	//				hint "ffe";
					if !(_select == _RUMtype) then {
						lbClear RUM_NumRArty_IDC;				
						{lbAdd [RUM_NumRArty_IDC,_x]} foreach ["1","3","5","10","15","20","25"];
						lbSetCurSel [RUM_NumRArty_IDC, 2];
					};
					if !(_select == _RUMtype) then {
						lbClear RUM_TimeArty_IDC;				
						{lbAdd [RUM_TimeArty_IDC,_x]} foreach ["N/A"];
						lbSetCurSel [RUM_TimeArty_IDC, 0];
					};
					_RUMtype = _select;
				};
				case 2: {
	//				hint "immsupp";
					if !(_select == _RUMtype) then {
						lbClear RUM_NumRArty_IDC;				
						{lbAdd [RUM_NumRArty_IDC,_x]} foreach ["N/A"];
						lbSetCurSel [RUM_NumRArty_IDC, 0];
					};
					if !(_select == _RUMtype) then {
						lbClear RUM_TimeArty_IDC;				
						{lbAdd [RUM_TimeArty_IDC,_x]} foreach ["2 Min"];
						lbSetCurSel [RUM_TimeArty_IDC, 0];
					};
					_RUMtype = _select;
				};
				case 3: {
	//				hint "supp";
					if !(_select == _RUMtype) then {
						lbClear RUM_NumRArty_IDC;				
						{lbAdd [RUM_NumRArty_IDC,_x]} foreach ["N/A"];
						lbSetCurSel [RUM_NumRArty_IDC, 0];
					};
					if !(_select == _RUMtype) then {
						lbClear RUM_TimeArty_IDC;				
						{lbAdd [RUM_TimeArty_IDC,_x]} foreach ["2 Min","3 Min"," 4 Min","5 Min"];
						lbSetCurSel [RUM_TimeArty_IDC, 0];
					};
					_RUMtype = _select;
				};
				default {
				};
			};
		};
		_tst = _select;
	};
	if(true)exitWith{};
};

RUM_ScootUpdate = {
private ["_dialog","_RUMtype","_tst","_sel","_type"];
	_tst = -1;
	_dialog = _this select 0;
	while {_dialog} do {
		_sel = lbCurSel RUM_ListArty_IDC;
		if!(_sel == -1)then{
			if!(_sel == _tst) then {
				_array = RUM_ArtyBatts select _sel;
				if ("scootable" in _array) then {
					lbClear RUM_TypeArty_IDC;
					{lbAdd [RUM_TypeArty_IDC,_x]} foreach ["AIMING FIRE","FIRE FOR EFFECT","IMMEDIATE SUPPRESSION","SUPPRESS","SCOOT"];
					lbSetCurSel [RUM_TypeArty_IDC, 0];
				}else{
					lbClear RUM_TypeArty_IDC;
					{lbAdd [RUM_TypeArty_IDC,_x]} foreach ["AIMING FIRE","FIRE FOR EFFECT","IMMEDIATE SUPPRESSION","SUPPRESS"];
					lbSetCurSel [RUM_TypeArty_IDC, 0];
				};
			};
		};
		_tst = _sel;
	};
	if(true)exitWith{};
};

RUM_FillListArty = {
private ["_list1","_arry","_veh","_text","_n"];
	_list1 = [];
	for [{_n = 0},{_n <= (count RUM_ArtyBatts - 1)},{_n = _n+1}] do {
		_arry = RUM_ArtyBatts select _n;
		_veh = _arry select 0;
		_text = _arry select 1;
		_list1 = _list1 + [_text];
   	};
	{lbAdd [RUM_ListArty_IDC,_x]} foreach _list1;
	
	if(true)exitWith{};
};


RUM_round_table = {
	private ["_typRid","_type","_arr","_typRstr","_shell"];
	_typRstr = _this select 0;
	_type = _this select 1;

	switch (_type) do {
		case "mortar":{_arr = RUM_Arty_class_mortar};
		case "howitzer":{_arr = RUM_Arty_class_howitzer};
		case "mlrs":{_arr = RUM_Arty_class_mlrs};
		default{"cunt thistle"};
	};

	_shell = _arr select (_arr find _typRstr)+1;

	[_typRstr,_shell];
};



if(true)exitwith{};